<admintpl file="header" />
</head>
<body>
	<div class="wrap">
		<ul class="nav nav-tabs">
			<li><a href="{:U('user/index')}">{:L('ADMIN_USER_INDEX')}</a></li>
			<li><a href="{:U('user/add')}">{:L('ADMIN_USER_ADD')}</a></li>
			<li class="active"><a>编辑管理员</a></li>
		</ul>
		<form method="post" class="form-horizontal js-ajax-form" action="{:U('User/edit_post')}" onsubmit="return checkform();">
			<fieldset>
				<div class="control-group">
					<label class="control-label">{:L('USERNAME')}</label>
					<div class="controls">
						<input type="text" name="user_login" value="{$user_login}">
					</div>
				</div>
				<div class="control-group">
					<label class="control-label">{:L('PASSWORD')}</label>
					<div class="controls">
						<input type="password" name="user_pass" value="" placeholder="******">
					</div>
				</div>
                <div class="control-group">
                    <label class="control-label">姓名</label>
                    <div class="controls">
                        <input type="text" name="user_nickname" value="{$user_nickname}">
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label">手机号</label>
                    <div class="controls">
                        <input type="text" name="user_phone" value="{$user_phone}">
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label">公司</label>
                    <div class="controls">
                        <input type="text" name="user_company" value="{$user_company}">
                    </div>
                </div>
                <div class="control-group" >
                    <label class="control-label">用户类型</label>
                    <div class="controls">
                        <foreach name="roles" item="vo">
                            <if condition="$vo['id'] != 1">
                                <label class="checkbox inline"><input  value="{$vo.id}"  type="radio" name="role_id" <if condition="$user_type==$vo['id']">checked</if>>&nbsp;&nbsp;{$vo.name}&nbsp;&nbsp;</label>
                            </if>
                        </foreach>
                    </div>
                </div>
			</fieldset>
			<div class="form-actions">
				<input type="hidden" name="id" value="{$id}" />
				<input type="hidden" name="model" value="{$model}"/>
				<button type="submit" class="btn btn-primary js-ajax-submit">{:L('SAVE')}</button>
				<a class="btn" href="javascript:history.back(-1);">{:L('BACK')}</a>
			</div>
		</form>
	</div>
	<script src="__PUBLIC__/js/common.js"></script>
	<script>
        function checkform(){
            var user_login = $("input[name='user_login']").val();
            var user_pass = $("input[name='user_pass']").val();
            var user_nicename = $("input[name='user_nickname']").val();
            var user_phone = $("input[name='user_phone']").val();
            var user_company = $("input[name='user_company']").val();
            if(user_login == ""){
                alert("用户名不能为空!"); return false;
            }
            if(user_pass == ""){
                alert("密码不能为空!");return false;
            }
            if(user_nicename == ''){
                alert("姓名不能为空!");return false;
            }
            if(user_phone == ''){
                alert("手机号不能为空!");return false;
            }
            if(user_phone.length != 11){
                alert("手机号输入有误!");return false;
            }
            if(user_company == ''){
                alert("公司不能为空!");return false;
            }
            return true;
        }
	</script>
</body>
</html>